package com.smartleanx.module.hrm.service.esign.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smartleanx.framework.tenant.core.aop.TenantIgnore;
import com.smartleanx.module.hrm.dal.mysql.esign.HrmETaskComponentsMapper;
import com.smartleanx.module.hrm.service.esign.eums.CustomComponentsTypeEnum;
import com.smartleanx.module.hrm.service.esign.service.HrmETaskComponentsService;
import com.smartleanx.module.hrm.service.esign.temp.po.HrmETaskComponents;
import com.smartleanx.module.hrm.service.esign.temp.po.HrmETempComponents;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * e签宝模板中的控件Service实现
 *
 * @author xzq
 * @since 2025-07-14 10:30:38
 */
@Service
public class HrmETaskComponentsServiceImpl extends ServiceImpl<HrmETaskComponentsMapper, HrmETaskComponents> implements HrmETaskComponentsService {


    @Override
    public List<HrmETaskComponents> getFillInComponents(Long taskId) {
        LambdaQueryWrapper<HrmETaskComponents> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HrmETaskComponents::getDataStatus,1);
        queryWrapper.eq(HrmETaskComponents::getTaskId,taskId);
        queryWrapper.ne(HrmETaskComponents::getComponentType, CustomComponentsTypeEnum.SIGN.getCode());
        List<HrmETaskComponents> list = list(queryWrapper);

        return list;
    }

    @Override
    public List<HrmETaskComponents> getFillInComponentsComponentIdIsNotNull(Long taskId) {
        LambdaQueryWrapper<HrmETaskComponents> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HrmETaskComponents::getDataStatus,1);
        queryWrapper.eq(HrmETaskComponents::getTaskId,taskId);
        queryWrapper.isNotNull(HrmETaskComponents::getComponentId);
        queryWrapper.ne(HrmETaskComponents::getComponentType, CustomComponentsTypeEnum.SIGN.getCode());
        List<HrmETaskComponents> list = list(queryWrapper);

        return list;
    }

    @Override
    @TenantIgnore
    public List<HrmETaskComponents> getFillInComponentsComponentIdIsNull(Long taskId) {
        LambdaQueryWrapper<HrmETaskComponents> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HrmETaskComponents::getDataStatus,1);
        queryWrapper.eq(HrmETaskComponents::getTaskId,taskId);
        queryWrapper.isNull(HrmETaskComponents::getComponentId);
        queryWrapper.ne(HrmETaskComponents::getComponentType, CustomComponentsTypeEnum.SIGN.getCode());
        List<HrmETaskComponents> list = list(queryWrapper);

        return list;
    }

    @Override
    public List<HrmETaskComponents> getFillInComponents(Long taskId, String componentType) {
        LambdaQueryWrapper<HrmETaskComponents> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HrmETaskComponents::getDataStatus,1);
        queryWrapper.eq(HrmETaskComponents::getTaskId,taskId);
        queryWrapper.eq(HrmETaskComponents::getComponentType, componentType);
        List<HrmETaskComponents> list = list(queryWrapper);

        return list;
    }
}
